<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue事件修饰符</title>
    <script type="text/javascript" src="../../js/vue.js"></script>
    <style>
        *{
            margin-top: 20px;
        }
        .demo1{
            height: 50px;
            background-color: blueviolet;
        }
        .box1{
            padding: 5px;
            background-color: blueviolet;
        }
        .box2{
            padding: 5px;
            background-color:chocolate
        }
        .list{
            background-color: peru;
            height: 200px;
            width: 200px;
            /* 滚动 */
            overflow: auto;  
        }
        li{
            height: 100px;
        }
    </style>
</head>
<body>
    <div id="root">
        <h4>测试{{name}}</h4>
        <!-- prevent 阻止默认行为 -->
        <a href="http://www.baidu.com" @click.prevent="showInfo">点击提示</a>
        <div class="demo1" @click="showInfo">
            <!-- stop 阻止事件冒泡 -->
            <button @click.stop="showInfo">点击提示</button>      
        </div>
       
        <!-- once 只触发一次 -->
        <button @click.once="showInfo">点击提示</button>      
       
        <!-- 事件捕获模式 capture -->
        <div class="box1" @click.capture="showMsg(1)">
            div1
            <div class="box2" @click="showMsg(2)">
                div2
            </div>
        </div>

        <!-- self 只有event.target是当前操作元素时才触发 -->
        <div class="demo1" @click.self="showInfo">
            <button @click="showInfo">点击提示</button>      
        </div>

        <!-- passive 事件的默认行为立即执行，无需等到回调执行完成 -->
        <!-- 滚动事件  @scroll  @wheel--鼠标滚轮 -->
        <ul class="list" @scroll.passive="demo">
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
        </ul>
    </div>

    <script type="text/javascript">
        Vue.config.performance = false;
        const vm = new Vue({
            el:'#root',
            data() {
                return {
                  name:'test'
                };
            },
            methods:{
                showInfo(e){
                    alert("zw")
                    console.log(e.target)
                },
                showMsg(msg){
                    console.log(msg)
                },
                demo(){
                    for(let i =0;i < 10000;i++){
                        console.log("@")
                    }
                    console.log("end")
                }
            }
        })

    </script>

</body>
</html>